package com.ruoyi.operateTraining.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.mateDevice.domain.DevicePreserve;
import com.ruoyi.mateDevice.domain.MateDevice;
import com.ruoyi.mateproduction.domain.SterilizationApply;
import com.ruoyi.operateTraining.domain.AdviceNotice;
import com.ruoyi.operateTraining.domain.AuditReport;
import com.ruoyi.operateTraining.domain.CustomerComplaint;
import com.ruoyi.operateTraining.domain.InternalAuditPlan;
import com.ruoyi.operateTraining.domain.InternalAuditSign;
import com.ruoyi.operateTraining.domain.ManageMeeting;
import com.ruoyi.operateTraining.domain.TrainingEvaluate;
import com.ruoyi.operateTraining.domain.TrainingInformation;
import com.ruoyi.operateTraining.domain.TrainingPlan;
import com.ruoyi.operateTraining.domain.TrainingSign;
import com.ruoyi.operateTraining.mapper.TrainingMapper;
import com.ruoyi.operateTraining.service.TrainingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author
 * @Version 1.0
 */
@RestController
@RequestMapping("/operateTraining")
public class OperateController extends BaseController {

    @Autowired
    private TrainingService trainingService;

    @Autowired
    private TrainingMapper trainingMapper;

    @PostMapping("/addTrainingPlan")
    public AjaxResult addTrainingPlan(@RequestBody TrainingPlan trainingPlan) {
        trainingPlan.setDeptId(SecurityUtils.getDeptId());
        int a = trainingService.addTrainingPlan(trainingPlan);
        if (a > 0) {
            return AjaxResult.success("添加成功");
        } else {
            return AjaxResult.error("添加失败,请联系技术员");
        }
    }


    @PostMapping("/addInternalAuditPlan")
    public AjaxResult addInternalAuditPlan(@RequestBody InternalAuditPlan internalAuditPlan) {
        internalAuditPlan.setDeptId(SecurityUtils.getDeptId());
        int a = trainingService.addInternalAuditPlan(internalAuditPlan);
        if (a > 0) {
            return AjaxResult.success("添加成功");
        } else {
            return AjaxResult.error("添加失败,请联系技术员");
        }
    }

    @GetMapping("/internalAuditPlanList")
    @ResponseBody
    public TableDataInfo internalAuditPlanList(
            @RequestParam(value = "beginTime", required = false) String beginTime,
            @RequestParam(value = "endTime", required = false) String endTime) {

        startPage();
        InternalAuditPlan internalAuditPlan = new InternalAuditPlan();
        internalAuditPlan.setBeginTime(beginTime);
        internalAuditPlan.setEndTime(endTime);
        internalAuditPlan.setDeptId(SecurityUtils.getDeptId());
        List<InternalAuditPlan> list = trainingMapper.internalAuditPlanList(internalAuditPlan);
        return getDataTable(list);
    }


    /**
     *
     */
    @GetMapping("/selectInternalAuditPlan")
    @ResponseBody
    public InternalAuditPlan selectInternalAuditPlan(@RequestParam(value = "internalId", required = false) Long internalId) {
        InternalAuditPlan internalAuditPlan = trainingMapper.selectInternalAuditPlan(internalId);
        return internalAuditPlan;
    }


    /**
     *
     */
    @GetMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam(value = "isProduction", required = false) String isProduction,
                              @RequestParam(value = "beginTime", required = false) String beginTime,
                              @RequestParam(value = "endTime", required = false) String endTime) {
        startPage();
        TrainingPlan trainingPlan = new TrainingPlan();
        trainingPlan.setIsProduction(isProduction);
        trainingPlan.setBeginTime(beginTime);
        trainingPlan.setEndTime(endTime);
        trainingPlan.setDeptId(SecurityUtils.getDeptId());
        List<TrainingPlan> list = trainingService.selectTrainingPlanList(trainingPlan);
        return getDataTable(list);
    }

    /**
     *
     */
    @GetMapping("/selectTrainingPlan")
    @ResponseBody
    public TrainingPlan selectTrainingPlan(@RequestParam(value = "trainingPlanId", required = false) Long trainingPlanId) {
        TrainingPlan trainingPlanResult = trainingMapper.selectTrainingPlan(trainingPlanId);
        return trainingPlanResult;
    }

    @PostMapping("/addTrainingSign")
    public AjaxResult addTrainingSign(@RequestBody TrainingSign trainingSign) {
        trainingSign.setDeptId(SecurityUtils.getDeptId());
        int a = trainingService.addTrainingSign(trainingSign);
        if (a > 0) {
            return AjaxResult.success("添加成功");
        } else {
            return AjaxResult.error("添加失败,请联系技术员");
        }
    }

    @PostMapping("/addTrainingInformation")
    public AjaxResult addTrainingInformation(@RequestBody TrainingInformation trainingInformation) {
        trainingInformation.setDeptId(SecurityUtils.getDeptId());
        int a = trainingMapper.addTrainingInformation(trainingInformation);
        if (a > 0) {
            return AjaxResult.success("添加成功");
        } else {
            return AjaxResult.error("添加失败,请联系技术员");
        }
    }


    @PostMapping("/addManageMeeting")
    public AjaxResult addManageMeeting(@RequestBody ManageMeeting manageMeeting) {
        manageMeeting.setDeptId(SecurityUtils.getDeptId());
        int a = trainingMapper.addManageMeeting(manageMeeting);
        if (a > 0) {
            return AjaxResult.success("添加成功");
        } else {
            return AjaxResult.error("添加失败,请联系技术员");
        }
    }

    @PostMapping("/addCustomerComplaint")
    public AjaxResult addCustomerComplaint(@RequestBody CustomerComplaint customerComplaint) {
        customerComplaint.setDeptId(SecurityUtils.getDeptId());
            int a = trainingMapper.addCustomerComplaint(customerComplaint);
        if (a > 0) {
            return AjaxResult.success("添加成功");
        } else {
            return AjaxResult.error("添加失败,请联系技术员");
        }
    }


    @GetMapping("/CustomerComplaintList")
    @ResponseBody
    public TableDataInfo CustomerComplaintList(
            @RequestParam(value = "beginTime", required = false) String beginTime,
            @RequestParam(value = "endTime", required = false) String endTime) {
        startPage();
        CustomerComplaint customerComplaint = new CustomerComplaint();
        customerComplaint.setBeginTime(beginTime);
        customerComplaint.setEndTime(endTime);
        customerComplaint.setDeptId(SecurityUtils.getDeptId());
        List<CustomerComplaint> list = trainingMapper.CustomerComplaintList(customerComplaint);
        return getDataTable(list);
    }

    @GetMapping("/selectCustomerComplaint")
    @ResponseBody
    public CustomerComplaint selectCustomerComplaint(@RequestParam(value = "complaintId", required = false) Long complaintId) {
        CustomerComplaint customerComplaint = trainingMapper.selectCustomerComplaint(complaintId);
        return customerComplaint;
    }


    @PostMapping("/addAdviceNotice")
    public AjaxResult addAdviceNotice(@RequestBody AdviceNotice adviceNotice) {
        adviceNotice.setDeptId(SecurityUtils.getDeptId());
        int a = trainingMapper.addAdviceNotice(adviceNotice);
        if (a > 0) {
            return AjaxResult.success("添加成功");
        } else {
            return AjaxResult.error("添加失败,请联系技术员");
        }
    }

    @GetMapping("/AdviceNoticeList")
    @ResponseBody
    public TableDataInfo AdviceNoticeList(
            @RequestParam(value = "beginTime", required = false) String beginTime,
            @RequestParam(value = "endTime", required = false) String endTime) {
        startPage();
        AdviceNotice adviceNotice = new AdviceNotice();
        adviceNotice.setBeginTime(beginTime);
        adviceNotice.setEndTime(endTime);
        adviceNotice.setDeptId(SecurityUtils.getDeptId());
        List<AdviceNotice> list = trainingMapper.AdviceNoticeList(adviceNotice);
        return getDataTable(list);
    }


    @GetMapping("/selectAdviceNotice")
    @ResponseBody
    public AdviceNotice selectAdviceNotice(@RequestParam(value = "adviceId", required = false) Long adviceId) {
        AdviceNotice adviceNotice = trainingMapper.selectAdviceNotice(adviceId);
        return adviceNotice;
    }


    @PostMapping("/addAuditReport")
    public AjaxResult addAuditReport(@RequestBody AuditReport auditReport) {
        auditReport.setDeptId(SecurityUtils.getDeptId());
        int a = trainingMapper.addAuditReport(auditReport);
        if (a > 0) {
            return AjaxResult.success("添加成功");
        } else {
            return AjaxResult.error("添加失败,请联系技术员");
        }
    }


    @GetMapping("/AuditReportList")
    @ResponseBody
    public TableDataInfo AuditReportList(
            @RequestParam(value = "beginTime", required = false) String beginTime,
            @RequestParam(value = "endTime", required = false) String endTime) {
        startPage();
        AuditReport auditReport = new AuditReport();
        auditReport.setBeginTime(beginTime);
        auditReport.setEndTime(endTime);
        auditReport.setDeptId(SecurityUtils.getDeptId());
        List<AuditReport> list = trainingMapper.AuditReportList(auditReport);
        return getDataTable(list);
    }


    @GetMapping("/selectAuditReport")
    @ResponseBody
    public AuditReport selectAuditReport(@RequestParam(value = "auditReportId", required = false) Long auditReportId) {
        AuditReport auditReport = trainingMapper.selectAuditReport(auditReportId);
        return auditReport;
    }


    @PostMapping("/addInternalAuditSign")
    public AjaxResult addInternalAuditSign(@RequestBody InternalAuditSign internalAuditSign) {
        internalAuditSign.setDeptId(SecurityUtils.getDeptId());
        int a = trainingService.addInternalAuditSign(internalAuditSign);
        if (a > 0) {
            return AjaxResult.success("添加成功");
        } else {
            return AjaxResult.error("添加失败,请联系技术员");
        }
    }

    @GetMapping("/InternalAuditSignList")
    @ResponseBody
    public TableDataInfo InternalAuditSignList(
            @RequestParam(value = "beginTime", required = false) String beginTime,
            @RequestParam(value = "endTime", required = false) String endTime) {
        startPage();
        InternalAuditSign internalAuditSign = new InternalAuditSign();
        internalAuditSign.setBeginTime(beginTime);
        internalAuditSign.setEndTime(endTime);
        internalAuditSign.setDeptId(SecurityUtils.getDeptId());
        List<InternalAuditSign> list = trainingMapper.InternalAuditSignList(internalAuditSign);
        return getDataTable(list);
    }


    @GetMapping("/selectInternalAuditSign")
    @ResponseBody
    public InternalAuditSign selectInternalAuditSign(@RequestParam(value = "internalSignId", required = false) Long internalSignId) {
        InternalAuditSign internalAuditSign = trainingMapper.selectInternalAuditSign(internalSignId);
        return internalAuditSign;
    }


    @GetMapping("/manageMeetingList")
    @ResponseBody
    public TableDataInfo manageMeetingList(
            @RequestParam(value = "beginTime", required = false) String beginTime,
            @RequestParam(value = "endTime", required = false) String endTime) {
        startPage();
        ManageMeeting manageMeeting = new ManageMeeting();
        manageMeeting.setBeginTime(beginTime);
        manageMeeting.setEndTime(endTime);
        manageMeeting.setDeptId(SecurityUtils.getDeptId());
        List<ManageMeeting> list = trainingMapper.manageMeetingList(manageMeeting);
        return getDataTable(list);
    }


    @GetMapping("/selectManageMeeting")
    @ResponseBody
    public ManageMeeting selectManageMeeting(@RequestParam(value = "meetingId", required = false) Long meetingId) {
        ManageMeeting manageMeeting = trainingMapper.selectManageMeeting(meetingId);
        return manageMeeting;
    }

    @GetMapping("/signList")
    @ResponseBody
    public TableDataInfo signList(@RequestParam(value = "isProduction", required = false) String isProduction,
                                  @RequestParam(value = "beginTime", required = false) String beginTime,
                                  @RequestParam(value = "endTime", required = false) String endTime) {
        startPage();
        TrainingSign trainingSign = new TrainingSign();
        trainingSign.setIsProduction(isProduction);
        trainingSign.setBeginTime(beginTime);
        trainingSign.setEndTime(endTime);
        trainingSign.setDeptId(SecurityUtils.getDeptId());
        List<TrainingSign> list = trainingService.selectSignList(trainingSign);
        return getDataTable(list);
    }

    @GetMapping("/informationList")
    @ResponseBody
    public TableDataInfo informationList(@RequestParam(value = "isProduction", required = false) String isProduction,
                                         @RequestParam(value = "beginTime", required = false) String beginTime,
                                         @RequestParam(value = "endTime", required = false) String endTime) {
        startPage();
        TrainingInformation trainingInformation = new TrainingInformation();
        trainingInformation.setIsProduction(isProduction);
        trainingInformation.setBeginTime(beginTime);
        trainingInformation.setEndTime(endTime);
        trainingInformation.setDeptId(SecurityUtils.getDeptId());
        List<TrainingInformation> list = trainingMapper.informationList(trainingInformation);
        return getDataTable(list);
    }

    @GetMapping("/selectTrainingSign")
    @ResponseBody
    public TrainingSign selectTrainingSign(@RequestParam(value = "signId", required = false) Long signId) {
        TrainingSign trainingSignResult = trainingMapper.selectTrainingSign(signId);
        return trainingSignResult;
    }

    @GetMapping("/selectTrainingInformation")
    @ResponseBody
    public TrainingInformation selectTrainingInformation(@RequestParam(value = "informationId", required = false) Long informationId) {
        TrainingInformation trainingInformation = trainingMapper.selectTrainingInformation(informationId);
        return trainingInformation;
    }


    @PostMapping("/addTrainingEvaluate")
    public AjaxResult addTrainingEvaluate(@RequestBody TrainingEvaluate trainingEvaluate) {
        trainingEvaluate.setDeptId(SecurityUtils.getDeptId());
        int a = trainingService.addTrainingEvaluate(trainingEvaluate);
        if (a > 0) {
            return AjaxResult.success("添加成功");
        } else {
            return AjaxResult.error("添加失败,请联系技术员");
        }
    }

    @GetMapping("/evaluateList")
    @ResponseBody
    public TableDataInfo evaluateList(@RequestParam(value = "isProduction", required = false) String isProduction,
                                      @RequestParam(value = "beginTime", required = false) String beginTime,
                                      @RequestParam(value = "endTime", required = false) String endTime) {
        startPage();
        TrainingEvaluate trainingEvaluate = new TrainingEvaluate();
        trainingEvaluate.setIsProduction(isProduction);
        trainingEvaluate.setBeginTime(beginTime);
        trainingEvaluate.setEndTime(endTime);
        trainingEvaluate.setDeptId(SecurityUtils.getDeptId());
        List<TrainingEvaluate> list = trainingService.selectEvaluateList(trainingEvaluate);
        return getDataTable(list);
    }

    @GetMapping("/selectTrainingEvaluate")
    @ResponseBody
    public TrainingEvaluate selectTrainingEvaluate(@RequestParam(value = "trainingEvaluateId", required = false) Long trainingEvaluateId) {
        TrainingEvaluate trainingEvaluateResult = trainingMapper.selectTrainingEvaluate(trainingEvaluateId);
        return trainingEvaluateResult;
    }


}
